package com.likeyoudo.views.api;

import com.likeyoudo.views.utils.HttpRequest;
import com.likeyoudo.common.constant.HttpMethod;

import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;

import java.util.concurrent.TimeUnit;

/**
 * @author LikeYouDo
 * @date 2023/12/19 19:46
 */
public class LoginApi {

    public static final String LOGIN = "Login.login";

    public static void login(RequestBody data) {
        HttpRequest.post(LOGIN, "/login",
                new Headers.Builder()
                        .add("isToken", "false"),
                data);
    }

    public static final String CAPTCHA = "Login.getCodeImg";

    public static void getCodeImg() {
        HttpRequest.request(CAPTCHA, HttpMethod.GET, "/captchaImage",
                new Headers.Builder()
                        .add("isToken", "false"),
                null, null,
                new OkHttpClient.Builder()
                        .callTimeout(20, TimeUnit.SECONDS)
                        .build());
    }

    public static final String LOGOUT = "Login.logout";

    public static void logout() {
        HttpRequest.post(LOGOUT, "/logout");
    }

    public static final String GET_INFO = "Login.getInfo";

    public static void getInfo() {
        HttpRequest.get(GET_INFO, "/getInfo");
    }
}
